示例#1
0
        public IDataInput Let <D>(out D v, int proj = 0x00ff) where D : IData, new()
        {
            try
            {
                int ord = ordinal++;
                if (!reader.IsDBNull(ord))
                {
                    string    str = reader.GetString(ord);
                    JsonParse p   = new JsonParse(str);
                    JObj      jo  = (JObj)p.Parse();
                    v = new D();
                    v.Read(jo, proj);

                    // add shard if any
                    IShardable sharded = v as IShardable;
                    if (sharded != null)
                    {
                        sharded.Shard = service.Shard;
                    }
                    return(this);
                }
            }
            catch
            {
            }
            v = default(D);
            return(this);
        }
示例#2
0
        public bool Get <D>(string name, ref D[] v, int proj = 0x00ff) where D : IData, new()
        {
            try
            {
                int ord = reader.GetOrdinal(name);
                if (!reader.IsDBNull(ord))
                {
                    string    str   = reader.GetString(ord);
                    JsonParse parse = new JsonParse(str);
                    JArr      ja    = (JArr)parse.Parse();
                    int       len   = ja.Count;
                    v = new D[len];
                    for (int i = 0; i < len; i++)
                    {
                        JObj jo  = ja[i];
                        D    obj = new D();
                        obj.Read(jo, proj);

                        // add shard if any
                        IShardable sharded = obj as IShardable;
                        if (sharded != null)
                        {
                            sharded.Shard = service.Shard;
                        }

                        v[i] = obj;
                    }
                    return(true);
                }
            }
            catch
            {
            }
            return(false);
        }
示例#3
0
        public bool Get <D>(string name, ref D v, int proj = 0x00ff) where D : IData, new()
        {
            try
            {
                int ord = reader.GetOrdinal(name);
                if (!reader.IsDBNull(ord))
                {
                    string    str = reader.GetString(ord);
                    JsonParse p   = new JsonParse(str);
                    JObj      jo  = (JObj)p.Parse();
                    v = new D();
                    v.Read(jo, proj);

                    // add shard if any
                    IShardable sharded = v as IShardable;
                    if (sharded != null)
                    {
                        sharded.Shard = service.Shard;
                    }
                    return(true);
                }
            }
            catch
            {
            }
            return(false);
        }
示例#4
0
        //
        // RESULTSET
        //

        public D ToObject <D>(int proj = 0x00ff) where D : IData, new()
        {
            D obj = new D();

            obj.Read(this, proj);

            // add shard if any
            IShardable sharded = obj as IShardable;

            if (sharded != null)
            {
                sharded.Shard = service.Shard;
            }

            return(obj);
        }
示例#5
0
        public List <D> ToList <D>(int proj = 0x00ff) where D : IData, new()
        {
            List <D> coll = new List <D>(32);

            while (Next())
            {
                D obj = new D();
                obj.Read(this, proj);

                // add shard if any
                IShardable sharded = obj as IShardable;
                if (sharded != null)
                {
                    sharded.Shard = service.Shard;
                }

                coll.Add(obj);
            }
            return(coll);
        }
示例#6
0
        public Map <K, D> ToMap <K, D>(Func <D, K> keyer, int proj = 0x00ff) where D : IData, new() where K : IEquatable <K>
        {
            int        initial = doerCtx?.Doer?.Limit ?? 32;
            Map <K, D> coll    = new Map <K, D>(initial);

            while (Next())
            {
                D obj = new D();
                obj.Read(this, proj);

                // add shard name if any
                IShardable sharded = obj as IShardable;
                if (sharded != null)
                {
                    sharded.Shard = service.Shard;
                }

                K key = keyer(obj);
                coll.Add(key, obj);
            }
            return(coll);
        }